; Translate upper case letters to lower case; don't change lower
; case letters and digits.  Translate other characters to spaces.
; author:  R. Detmer    revised: 10/97

.386
.MODEL FLAT

ExitProcess PROTO NEAR32 stdcall, dwExitCode:DWORD
INCLUDE io.h
PUBLIC _start
cr          EQU    0dh   ; carriage return character
Lf          EQU    0ah   ; linefeed character

.STACK  4096             ; reserve 4096-byte stack

.DATA
string      BYTE   'This is a #!$& STRING',0
strLength   EQU    $ - string - 1
label1      BYTE   'Original string   ->',0
label2      BYTE   cr, Lf, 'Translated string ->',0
crlf        BYTE   cr, Lf, 0
table       BYTE   48 DUP (' '), '0123456789', 7 DUP (' ')
            BYTE   'abcdefghijklmnopqrstuvwxyz', 6 DUP (' ')
            BYTE   'abcdefghijklmnopqrstuvwxyz', 133 DUP (' ')

.CODE
_start:     output label1       ; display original string
            output string
            output crlf

            mov    ecx, strLength ; string length
            lea    ebx, table     ; address of translation table
            lea    esi, string    ; address of string
            lea    edi, string    ; destination also string
forIndex:   lodsb                 ; copy next character to AL
            xlat                  ; translate character
            stosb                 ; copy character back into string
            loop   forIndex       ; repeat for all characters

            output label2         ; display altered string
            output string
            output crlf

            INVOKE  ExitProcess, 0
            END

